<?php

declare(strict_types=1);
/**
 * This file is part of MoChat.
 * @link     https://mo.chat
 * @document https://mochat.wiki
 * @contact  group@mo.chat
 * @license  https://github.com/mochat-cloud/mochat/blob/master/LICENSE
 */
namespace MoChat\App\WorkEmployee\Action\Dashboard;

use Hyperf\Di\Annotation\Inject;
use Hyperf\HttpServer\Annotation\Controller;
use Hyperf\HttpServer\Annotation\Middleware;
use Hyperf\HttpServer\Annotation\Middlewares;
use Hyperf\HttpServer\Annotation\RequestMapping;
use MoChat\App\Common\Middleware\DashboardAuthMiddleware;
use MoChat\App\WorkDepartment\Queue\SyncDepartmentQueue;
use MoChat\App\WorkEmployee\Queue\EmployeeQueue;
use MoChat\Framework\Action\AbstractAction;

/**
 * 同步企业成员 - 页面.组织架构-同步企业微信通讯录.
 * @Controller
 */
class SyncEmployee extends AbstractAction
{
    /**
     * @var EmployeeQueue
     */
    protected $employeeQueue;

    /**
     * @Inject
     * @var SyncDepartmentQueue
     */
    protected $syncDepartmentQueue;

    /**
     * @Middlewares({
     *     @Middleware(DashboardAuthMiddleware::class)
     * })
     * @RequestMapping(path="/dashboard/workEmployee/syncEmployee", methods="PUT")
     */
    public function handle()
    {
//        $params['corpIds'] = user()['corpIds'];
//        //同步成员信息
//        make(EmployeeQueue::class)->handle($params['corpIds']);
        $corpId = (int) user()['corpIds'][0];
        $this->syncDepartmentQueue->syncDepartmentByCorpId(['corpId' => $corpId]);
    }
}
